<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>购物订单管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
		function setMoneyType(){
			var status = $("#formStatus").val();
			if (status == 0){
				$(".money-type").attr("disabled",false);
			}
			else $(".money-type").attr("disabled",true);
			
		}
		$(document).ready(function() {
			setMoneyType();
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/shop/order/manage/">购物订单列表</a></li>
		<li class="active"><a
			href="${ctx}/shop/order/manage/form?id=${shopOrder.id}">购物订单<shiro:hasPermission
					name="shop:order:manage:edit">${not empty shopOrder.id?'修改':'添加'}</shiro:hasPermission>
				<shiro:lacksPermission name="shop:order:manage:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<br />
	<form:form id="inputForm" modelAttribute="shopOrder"
		action="${ctx}/shop/order/manage/save" method="post"
		class="form-horizontal">
		<form:hidden path="id" />
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">订单编号：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="64"
					class="input-xlarge required" disabled="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单总金额：</label>
			<div class="controls">
				<form:input path="totalAmount" htmlEscape="false"
					class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">商品总金额：</label>
			<div class="controls">
				<form:input path="totalAmountProduct" htmlEscape="false"
					class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">配送费：</label>
			<div class="controls">
				<form:input path="freight" htmlEscape="false" class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
            <label class="control-label">订单支付时间：</label>
            <div class="controls">
                <input name="payTime" type="text" readonly="readonly"
                    maxlength="20" class="input-medium Wdate "
                    value="<fmt:formatDate value="${shopOrder.payTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
            </div>
        </div>
		<div class="control-group">
			<label class="control-label">订单创建时间：</label>
			<div class="controls">
				<input name="createTime" type="text" readonly="readonly"
					maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${shopOrder.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">下单人：</label>
			<div class="controls">
				<form:input path="freight" htmlEscape="false" class="input-xlarge money-type" value="${shopOrder.account.username}"/>
				<span class="help-inline"><font color="red">*</font> </span>
				<%-- <sys:treeselect id="account" name="account.id"
					value="${shopOrder.account.id}" labelName="account.name"
					labelValue="${shopOrder.account.username}" title="用户"
					url="/sys/office/treeData?type=3" cssClass="required"
					allowClear="true" notAllowSelectParent="true" />
				<span class="help-inline"><font color="red">*</font> </span> --%>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单状态：</label>
			<div class="controls">
				<form:select path="status" style="width:120px;" id="formStatus" onchange="setMoneyType()">
					<c:choose>
                  		<c:when test="${shopOrder.status == '1'}">
							<form:option value="1" disabled="disabled">待付款</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '2'}">
                  			<form:option value="2">已付款</form:option>
                  			<form:option value="3">订单确认</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '3'}">
                  			<form:option value="3">订单确认</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '4'}">
                  			<form:option value="4">已发货</form:option>
							<form:option value="5">完成交易</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '5'}">
							<form:option value="5">完成交易</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '6'}">
							<form:option value="6">取消</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '7'}">
							<form:option value="7">申请退款</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '8'}">
							<form:option value="8">退款驳回</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '9'}">
							<form:option value="9">退款成功</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '10'}">
							<form:option value="10">退款失败</form:option>
                  		</c:when>
                  	</c:choose>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:input path="comment" htmlEscape="false" maxlength="255"
					class="input-xlarge " disabled="true"/>
			</div>
		</div>

		<div class="form-actions">
            <shiro:hasPermission name="shop:order:manage:edit">
                <input id="btnSubmit" class="btn btn-primary" type="submit"
                    value="保 存" />&nbsp;</shiro:hasPermission>
            <input id="btnCancel" class="btn" type="button" value="返 回"
                onclick="history.go(-1)" />
        </div>

		<!-- 商品列表 -->
		<div style="margin:20px 20px 20px 20px ;margin-b:20px; border-bottom:1px #ccc solid;"></div>
		<div style="text-align:center"><h3>商品列表</h3></div>
		<div class="control-group">
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th>商品名称</th>
						<th>商品货号</th>
						<th>商品单价</th>
						<th>商品数量</th>
						<th>小计</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${shopOrder.shopOrderInfoList}"
						var="shopOrderInfo">
						<tr>
							<td>${shopOrderInfo.name }</td>
							<td>${shopOrderInfo.code }</td>
							<td>${shopOrderInfo.price }</td>
							<td>${shopOrderInfo.count }</td>
							<td>${shopOrderInfo.totalAmount }</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>

        <!-- 订单发货信息 -->
        <div style="margin:20px 20px 20px 20px ;margin-b:20px; border-bottom:1px #ccc solid;"></div>
	    <div style="text-align:center"><h3>订单发货信息</h3></div>
	    <div class="control-group">
	        <table class="table table-striped table-bordered table-condensed">
	           <thead>
	               <tr>
                        <th>快递单号</th>
                        <th>快递公司</th>
                        <th>收货人</th>
                        <th>电话号码</th>
                        <th>收货地址</th>
                        <th>备注信息</th>
                    </tr>
	           </thead>
	           <tbody>
	               <tr>
                       <td>${shopOrder.shopOrderReceiving.code }</td>
                       <td>${shopOrder.shopOrderReceiving.company }</td>
                       <td>${shopOrder.shopOrderReceiving.name }</td>
                       <td>${shopOrder.shopOrderReceiving.telephone }</td>
                       <td>${shopOrder.shopOrderReceiving.address }</td>
                       <td>${shopOrder.shopOrderReceiving.comment }</td>
                   </tr>
	           </tbody>
	        </table>
	    </div>

	    <!-- 发票信息 -->
	    <div style="margin:20px 20px 20px 20px ;margin-b:20px; border-bottom:1px #ccc solid;"></div>
	    <div style="text-align:center"><h3>发票信息</h3></div>
	    <!-- 普通增值税发票 -->
        <div class="control-group" ${shopOrder.shopOrderReceipt.type eq 2 ? 'style="display: none;"' : 'style="display: block;"' }>
            <table class="table table-striped table-bordered table-condensed">
                <thead>
                   <tr>
                        <th>发票抬头</th>
                        <th>发票类型</th>
                    </tr>
               </thead>
               <tbody>
                   <tr>
                       <td>${shopOrder.shopOrderReceipt.head }</td>
                       <td>${shopOrder.shopOrderReceipt.type eq 1 ? '普通增值税发票' : '专用增值税发票'}</td>
                   </tr>
               </tbody>
            </table>
        </div>
	    <!-- 专用增值税发票 -->
        <div class="control-group" ${shopOrder.shopOrderReceipt.type eq 1 ? 'style="display: none;"' : 'style="display: block;"' }>
            <table class="table table-striped table-bordered table-condensed">
               <thead>
                   <tr>
                        <th>单位名称</th>
                        <th>纳税人识别码</th>
                        <th>注册地址</th>
                        <th>电话号码</th>
                        <th>开户银行</th>
                        <th>银行账户</th>
                        <th>发票类型</th>
                    </tr>
               </thead>
               <tbody>
                   <tr>
                       <td>${shopOrder.shopOrderReceipt.name }</td>
                       <td>${shopOrder.shopOrderReceipt.code }</td>
                       <td>${shopOrder.shopOrderReceipt.address }</td>
                       <td>${shopOrder.shopOrderReceipt.telephone }</td>
                       <td>${shopOrder.shopOrderReceipt.bankName }</td>
                       <td>${shopOrder.shopOrderReceipt.bankAccount }</td>
                       <td>${shopOrder.shopOrderReceipt.type eq 1 ? '普通增值税发票' : '专用增值税发票'}</td>
                   </tr>
               </tbody>
            </table>
        </div>
	</form:form>
	<div style="margin:20px 20px 20px 20px ;margin-b:20px; border-bottom:1px #ccc solid;"></div>
	<form:form id="inputOperateForm" modelAttribute="shopOrder"
        action="${ctx}/shop/order/shopOperate/save" method="post"
        class="form-horizontal">
        <!-- 操作信息 -->
        <div style="text-align:center"><h3>操作记录</h3></div>
        <div class="control-group">
            <table class="table table-striped table-bordered table-condensed">
                <thead>
                    <tr>
                        <th>操作者</th>
                        <th>操作时间</th>
                        <th>订单状态</th>
                        <th>描述</th>
                        <th>备注</th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach items="${shopOrder.shopOrderOperateList}"
                        var="shopOrderOperate">
                        <tr>
                            <td>${shopOrderOperate.createUser }</td>
                            <td><fmt:formatDate value="${shopOrderOperate.createTime }" pattern="yyyy-MM-dd hh:mm:ss"/></td>
                            <td>
                            <c:choose>
                              <c:when test="${shopOrderOperate.status== '1'}">
                                                                                               待付款
							   </c:when>
							   <c:when test="${shopOrderOperate.status== '2'}">
                                                                                               已付款
                               </c:when>
                               <c:when test="${shopOrderOperate.status== '3'}">
                                                                                               订单确认
                               </c:when>
                               <c:when test="${shopOrderOperate.status== '4'}">
                                                                                               已发货
                               </c:when>
                               <c:when test="${shopOrderOperate.status== '5'}">
                                                                                              交易完成
                               </c:when>
                               <c:when test="${shopOrderOperate.status== '6'}">
                                                                                              取消
                               </c:when>
                            </c:choose>
                            </td>
                            <td>${shopOrderOperate.describes }</td>
                            <td>${shopOrderOperate.comment }</td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
        </div>
    </form:form>
</body>
</html>